<?php

declare(strict_types=1);

namespace App\Request;

use App\Constants\ErrorCode;
use Hyperf\Contract\ValidatorInterface;
use Hyperf\Validation\Request\FormRequest;

class Request extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    protected function failedValidation(ValidatorInterface $validator): void
    {
        throw_error($validator->errors()->first(), ErrorCode::BAD_REQUEST);
    }
}
